package com.example.pceb.controller;

import com.example.pceb.entity.BorrowRecord;
import com.example.pceb.entity.Resources;
import com.example.pceb.service.BorrowService;
import com.example.pceb.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/api/resource")
public class ResourceController {
    @Autowired
    private ResourceService resourceService;

    @GetMapping("/list")
    public List<Resources> list() {
        return resourceService.getAll();
    }

    @PostMapping("/add")
    public void add(@RequestBody Resources resource) {
        resourceService.add(resource);
    }

    @PostMapping("/update")
    public void update(@RequestBody Resources resource) {
        resourceService.update(resource);
    }
}


